<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ES6模块化</title>
</head>

<body>

</body>
<script type="module">
/*     import { num, person } from "./xiaoxin.js"
    console.log(num)        // 45
    console.log(person)     // {name: '笑心', age: 20}

    try {
        num = 100;
    } catch (error) {
        console.log(error)  // TypeError: Assignment to constant variable.
    }

    try {
        person = {};
    } catch (error) {
        console.log(error)  // TypeError: Assignment to constant variable.
    }
    person.age = 20;

    setTimeout(() => {
        console.log(num)        // 100
        console.log(person)     // {name: '笑心', age: 20}
    }, 2000);

    import {person as per} from "./xiaoxin.js"
    console.log(per === person)         //  true */

    import person from "./xiaoxin.js"
    console.log(person)     // {name: '笑心', age: 20}
    try {
        person = {};        // TypeError: Assignment to constant variable.
    } catch (error) {
        console.log(error)
    }

    setTimeout(() => {
        console.log(person);    // {name: '笑心', age: 18}
        import("./xiaoxin.js").then((obj)=>{
            console.log(obj === person)     // false
        })                      
    }, 2000);

    import haha from "./xiaoxin.js"
    console.log(haha)                   // {name: '笑心', age: 20}
    console.log(haha === person);       // true

    
</script>

</html>